package com.ruoyi.web.controller.websql;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.websql.service.ISqlDatasourceService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author xudengyu
 */
// TODO sql编辑器
@RestController
@RequestMapping("/websql/sqlmanager")
public class SqlManagerController {

    @Resource
    private ISqlDatasourceService sqlDatasourceService;

    // 查询数据库所有表及字段
    @RequestMapping("/findTableFieldByDatabase/{database}")
    public AjaxResult findTableFieldByDatabase(@PathVariable("database") String database){
        return sqlDatasourceService.findTableFieldByDatabase(database);
    }

    // TODO 左侧数据库属性菜单列表
    @RequestMapping("/metaTreeTableList")
    public AjaxResult metaTreeTableList() {
        return AjaxResult.success(sqlDatasourceService.metaTreeTableList());
    }

}
